<template>
	<tn-tabbar fixed @change="tabbarChangeEvent" v-model="currentIndex">
		<tn-tabbar-item text="首页" icon="home" active-icon="home-fill" />
		<tn-tabbar-item text="我的" icon="my" active-icon="my-fill" />
	</tn-tabbar>
	<view class="contact-us" @click="goFeedback()">
		<img :src="'/static/feedback.png'" />
		<text>反馈</text>
	</view>
</template>

<script setup lang="ts">
	import { ref } from 'vue'
	import {
		goHome,
		goUserCenter,
		goFeedback
	} from '@/utils/utils'

	const pages = getCurrentPages(); // 获取页面栈
	const currentPage = pages[pages.length - 1]; // 获取当前页面的对象
	const currentIndex = ref(0)
	
	if (currentPage.route === 'pages/my/index') {
		currentIndex.value = 1;
	}
	const tabbarChangeEvent = (index : string | number) => {
		console.log('index', index)
		if (index === 1) {
			goUserCenter()
		} else {
			goHome()
		}
	}
</script>

<style lang="scss" scoped>
	.contact-us {
    align-items: center;
    background: #b3b3b3;
    border-radius: 2rpx;
    bottom: 20%;
    display: flex;
    height: 74rpx;
    justify-content: center;
    position: fixed;
    right: 26rpx;
    width: 148rpx;
    z-index: 300;
	color: #505050;
	    font-family: PingFangSC-Regular, PingFang SC;
	    font-size: 26rpx;
	    font-weight: 400;
	img {
	    height: 32rpx;
	    margin-right: 2rpx;
	    width: 32rpx;
	}
}
</style>